<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第一题</title>
</head>

<body>
    <script>
        let string = 'ababfasbasfbfdbfbafbafb'
        const arr = []
        for (let k in string) {
            arr.push(string[k])
        }
        function getArray(arr) {
            let a = {}
            arr.map(function (item) {
                if (a[item]) {
                    a[item] += 1
                } else {
                    a[item] = 1
                }
            })
            console.log(a)
            let max = 0
            let index = 0
            for (let k in a) {
                if (a[k] > max) {
                    max = a[k]
                    index = k
                }
            }
            console.log(`出现最多的符号为：${index}，次数为：${max}`);
        }
        getArray(arr)
    </script>
</body>

</html>